package com.zzw.zim.common.config;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springdoc.core.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <p>项目名称: zzw-tech </p>
 * <p>包名称: com.zzw.bridge.common.config </p>
 * <p>描述: 接口文档配置 </p>
 * <p> 接口文档配置 </p>
 * <p>创建时间: 2022/11/14 16 </p>
 *
 * @author coco
 * @version v1.0
 */
@Configuration
public class SwaggerConfig {
	@Bean
	public GroupedOpenApi allApi () {
		String[] paths = {"/**"};
		String[] packagedToMatch = {"com.zzw"};
		return GroupedOpenApi.builder().group("所有接口").pathsToMatch(paths).packagesToScan(packagedToMatch).build();
	}

	@Bean
	public OpenAPI customOpenApi () {
		Contact contact = new Contact();
		contact.setName("致筑网");

		OpenAPI openAPI = new OpenAPI().info(new Info().title("监测平台").description("监测平台").contact(contact).version("2.0").termsOfService("https://mis.zhizhuwang.online"));
		openAPI.addSecurityItem(new SecurityRequirement().addList("api_key")).components(new Components().addSecuritySchemes("api_key", new SecurityScheme().name("Authorization").type(SecurityScheme.Type.APIKEY).in(SecurityScheme.In.HEADER)));

		return openAPI;
	}
}
